import 'dart:io';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:flutter_native_image/flutter_native_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart' hide MultipartFile hide FormData;
import 'package:image_picker/image_picker.dart';
import 'package:intl/intl.dart';
import 'package:kzcity_picker/kzcity_picker.dart';
import 'package:multi_image_picker/multi_image_picker.dart';
import 'package:yp/helper.dart';

import 'crop_widget.dart';
import 'logic.dart';
import 'state.dart';

class MemberInformationPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _MemberInformationPage();
  }
}

class _MemberInformationPage extends State<MemberInformationPage> {
  final MemberInformationLogic logic = Get.put(MemberInformationLogic());
  final MemberInformationState state = Get.find<MemberInformationLogic>().state;

  List<Asset> images = [];
  List newImg = [];
  Future<void> loadAssets(index) async {
    if (images == null) {
      images = List<Asset>();
      Asset asset;
    }
    if (index == 2) {
      // var imagesList = [];
      // try {
      //   imagesList = await MultiImagePicker.pickImages(
      //     maxImages: 1,
      //     enableCamera: false,
      //     cupertinoOptions: CupertinoOptions(takePhotoIcon: "chat"),
      //     materialOptions: MaterialOptions(
      //       actionBarColor: "#FCCD00",
      //       actionBarTitle: "选择图片",
      //       allViewTitle: "所有图片",
      //       useDetailsView: false,
      //       selectCircleStrokeColor: "#000000",
      //     ),
      //   );
      //   if (imagesList.length != 0) {
      //     images = imagesList;
      //     Navigator.of(Get.context).pop();
      //   }
      // } on Exception catch (e) {
      //   Navigator.of(Get.context).pop();
      // }
      // if (imagesList.length == 0) return;
      // // state.headPortraitAsset = images[0];
      // ByteData byteData = await images[0].getByteData();
      // state.imageData = byteData.buffer.asUint8List();
      final ImagePicker _picker = ImagePicker();

      var img = await _picker.pickImage(source: ImageSource.gallery);
      var _image = File(img.path);
      Get.back();
      Get.to(CropWidget(source: _image)).then((value) {
        print("============$value");
        if (value != null) {
          File f = value;
          state.imageData = f.readAsBytesSync();
          logic.update();
        }
      });
    } else {
      try {
        final ImagePicker _picker = ImagePicker();
        var img = await _picker.pickImage(source: ImageSource.camera);
        var _image = File(img.path);
        Get.back();
        Get.to(CropWidget(source: _image)).then((value) {
          print("============$value");
          if (value != null) {
            File f = value;
            state.imageData = f.readAsBytesSync();
            logic.update();
          }
        });
        // var _image;
        // var data;
        // var imageData;
        // if (Platform.isAndroid) {
        //   _image = File(img.path).path;
        //   var compressedFile = await FlutterNativeImage.compressImage(
        //     _image,
        //     quality: 10,
        //   );
        //   imageData = await compressedFile.readAsBytes();
        // } else {
        //   _image = File(img.path).path;
        //   var compressedFile = await FlutterNativeImage.compressImage(
        //     _image,
        //     quality: 10,
        //   );
        //   data = await rootBundle.load(compressedFile.path);
        //   imageData = data.buffer.asUint8List();
        // }
        // Navigator.of(Get.context).pop();
        // state.imageData = imageData;
        // logic.update();
      } on Exception catch (e) {
        Navigator.of(Get.context).pop();
      }
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        elevation: 0,
        backgroundColor: Color(0xffEA5504),
        title: Text(
          '会员信息',
          style: TextStyle(
            color: Colors.white,
            fontSize: 17,
          ),
        ),
        iconTheme: IconThemeData(
          color: Colors.white,
        ),
      ),
      body: GetBuilder<MemberInformationLogic>(
        builder: (logic) {
          return Container(
            color: Color(0xffF8F8F8),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Expanded(
                  child: Container(
                    child: ListView(
                      children: [
                        Container(
                          //padding: EdgeInsets.symmetric(horizontal: setWidth(26)),
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: [
                              Stack(
                                alignment: Alignment.center,
                                children: [
                                  Container(
                                    width: Get.width,
                                    height: setWidth(200),
                                    color: Colors.white,
                                  ),
                                  InkWell(
                                    onTap: () {
                                      print('会员信息 点击事件！！！ ');
                                      selectImage(context);
                                    },
                                    child: ClipOval(
                                      // headPortraitStr
                                      child: state.imageData != null
                                          ? Image.memory(
                                              state.imageData,
                                              width: setWidth(140),
                                              height: setWidth(140),
                                              fit: BoxFit.cover,
                                            )
                                          : CachedNetworkImage(
                                              imageUrl: state.headPortraitStr,
                                              width: setWidth(140),
                                              height: setWidth(140),
                                              fit: BoxFit.cover,
                                              errorWidget:
                                                  (context, url, error) {
                                                return Image.asset(
                                                  'assets/images/defaultAvatar_image.png',
                                                  width: setWidth(140),
                                                  height: setWidth(140),
                                                  fit: BoxFit.cover,
                                                );
                                              },
                                            ),
                                    ),
                                  ),
                                ],
                              ),
                              Padding(
                                padding: EdgeInsets.only(
                                  left: setWidth(20),
                                  top: setWidth(40),
                                  bottom: setWidth(16),
                                ),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  children: [
                                    Text.rich(
                                      TextSpan(
                                        children: [
                                          TextSpan(
                                            text: '完善个人信息',
                                            style: TextStyle(
                                              color: Color(0xff222222),
                                              fontSize: 14,
                                            ),
                                          ),
                                          WidgetSpan(
                                            child: SizedBox(
                                              width: setWidth(16),
                                            ),
                                          ),
                                          TextSpan(
                                            text: '有助于为您提供更好的会员服务',
                                            style: TextStyle(
                                              color: Color(0xff666666),
                                              fontSize: 12,
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ),
                        Container(
                          color: Colors.white,
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              // 账号
                              Container(
                                height: setWidth(88),
                                padding: EdgeInsets.symmetric(
                                    horizontal: setWidth(50)),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  children: [
                                    Container(
                                      width: setWidth(156),
                                      alignment: Alignment.centerLeft,
                                      child: Text(
                                        '账号',
                                        style: TextStyle(
                                          color: Color(0xff333333),
                                          fontSize: 13,
                                        ),
                                      ),
                                    ),
                                    Expanded(
                                      child: Container(
                                        child: TextField(
                                          controller:
                                              state.accountNumberController,
                                          style: TextStyle(
                                            color: Color(0xff222222),
                                            fontSize: 13,
                                          ),
                                          maxLines: 1,
                                          enabled: false,
                                          decoration: InputDecoration(
                                            fillColor: Colors.white,
                                            filled: true,
                                            contentPadding: EdgeInsets.zero,
                                            hintText: '请输入账号',
                                            hintStyle: TextStyle(
                                              color: Color(0xffcccccc),
                                              fontSize: 13,
                                            ),
                                            enabledBorder: OutlineInputBorder(
                                              // 设置输入框可编辑时的边框样式
                                              borderRadius: BorderRadius.all(
                                                  Radius.circular(
                                                      0)), // 设置边框四个角的弧度
                                              borderSide: BorderSide(
                                                // 用来配置边框的样式
                                                color: Colors
                                                    .transparent, // 设置边框的颜色
                                                width: setWidth(1), // 设置边框的粗细
                                              ),
                                            ),
                                            focusedBorder: OutlineInputBorder(
                                              // 用来配置输入框获取焦点时的颜色
                                              borderRadius: BorderRadius.all(
                                                  Radius.circular(
                                                      0)), // 设置边框四个角的弧度
                                              borderSide: BorderSide(
                                                // 用来配置边框的样式
                                                color: Colors
                                                    .transparent, // 设置边框的颜色
                                                width: setWidth(1), // 设置边框的粗细
                                              ),
                                            ),
                                            disabledBorder: OutlineInputBorder(
                                              // 设置输入框可编辑时的边框样式
                                              borderRadius: BorderRadius.all(
                                                  Radius.circular(
                                                      0)), // 设置边框四个角的弧度
                                              borderSide: BorderSide(
                                                // 用来配置边框的样式
                                                color: Colors
                                                    .transparent, // 设置边框的颜色
                                                width: setWidth(1), // 设置边框的粗细
                                              ),
                                            ),
                                          ),
                                        ),
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                              Divider(
                                height: setWidth(1),
                                color: Color(0xffEEEEEE),
                                indent: setWidth(38),
                                endIndent: 0,
                              ),
                              // 姓名
                              Container(
                                height: setWidth(88),
                                padding: EdgeInsets.symmetric(
                                    horizontal: setWidth(50)),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  children: [
                                    Container(
                                      width: setWidth(156),
                                      alignment: Alignment.centerLeft,
                                      child: Row(
                                        children: [
                                          Text(
                                            '姓名',
                                            style: TextStyle(
                                              color: Color(0xff333333),
                                              fontSize: 13,
                                            ),
                                          ),
                                          Text(
                                            '*',
                                            style: TextStyle(
                                              color: Colors.red,
                                              fontSize: 13,
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                      child: Container(
                                        child: TextField(
                                          controller: state.nameController,
                                          style: TextStyle(
                                            color: Color(0xff222222),
                                            fontSize: 13,
                                          ),
                                          maxLines: 1,
                                          decoration: InputDecoration(
                                            fillColor: Colors.white,
                                            filled: true,
                                            contentPadding: EdgeInsets.zero,
                                            hintText: '请输入姓名',
                                            hintStyle: TextStyle(
                                              color: Color(0xffcccccc),
                                              fontSize: 13,
                                            ),
                                            enabledBorder: OutlineInputBorder(
                                              // 设置输入框可编辑时的边框样式
                                              borderRadius: BorderRadius.all(
                                                  Radius.circular(
                                                      0)), // 设置边框四个角的弧度
                                              borderSide: BorderSide(
                                                // 用来配置边框的样式
                                                color: Colors
                                                    .transparent, // 设置边框的颜色
                                                width: setWidth(1), // 设置边框的粗细
                                              ),
                                            ),
                                            focusedBorder: OutlineInputBorder(
                                              // 用来配置输入框获取焦点时的颜色
                                              borderRadius: BorderRadius.all(
                                                  Radius.circular(
                                                      0)), // 设置边框四个角的弧度
                                              borderSide: BorderSide(
                                                // 用来配置边框的样式
                                                color: Colors
                                                    .transparent, // 设置边框的颜色
                                                width: setWidth(1), // 设置边框的粗细
                                              ),
                                            ),
                                          ),
                                        ),
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                              Divider(
                                height: setWidth(1),
                                color: Color(0xffEEEEEE),
                                indent: setWidth(38),
                                endIndent: 0,
                              ),
                              // 生日
                              Container(
                                height: setWidth(88),
                                padding: EdgeInsets.symmetric(
                                    horizontal: setWidth(50)),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  children: [
                                    Container(
                                      width: setWidth(156),
                                      alignment: Alignment.centerLeft,
                                      child: Row(
                                        children: [
                                          Text(
                                            '生日',
                                            style: TextStyle(
                                              color: Color(0xff333333),
                                              fontSize: 13,
                                            ),
                                          ),
                                          Text(
                                            '*',
                                            style: TextStyle(
                                              color: Colors.red,
                                              fontSize: 13,
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                      child: InkWell(
                                        onTap: () {
                                          if (state.birthdayBool) {
                                            DatePicker.showDatePicker(
                                              context,
                                              showTitleActions: true,
                                              minTime: DateTime(1900, 1, 1),
                                              maxTime: DateTime.now(),
                                              onConfirm: (date) {
                                                var time =
                                                    '${DateFormat("yyyy-MM-dd").format(date)}';
                                                setState(() {
                                                  state.timeStr = time;
                                                  state.birthdayController
                                                      .text = time;
                                                });
                                              },
                                              currentTime: DateTime.now(),
                                              locale: LocaleType.zh,
                                            );
                                          }
                                        },
                                        child: Container(
                                          child: TextField(
                                            controller:
                                                state.birthdayController,
                                            style: TextStyle(
                                              color: Color(0xff222222),
                                              fontSize: 13,
                                            ),
                                            maxLines: 1,
                                            enabled: false,
                                            decoration: InputDecoration(
                                              fillColor: Colors.white,
                                              filled: true,
                                              contentPadding: EdgeInsets.zero,
                                              hintText: '点击选择出生年月日',
                                              hintStyle: TextStyle(
                                                color: Color(0xffcccccc),
                                                fontSize: 13,
                                              ),
                                              enabledBorder: OutlineInputBorder(
                                                // 设置输入框可编辑时的边框样式
                                                borderRadius: BorderRadius.all(
                                                    Radius.circular(
                                                        0)), // 设置边框四个角的弧度
                                                borderSide: BorderSide(
                                                  // 用来配置边框的样式
                                                  color: Colors
                                                      .transparent, // 设置边框的颜色
                                                  width: setWidth(1), // 设置边框的粗细
                                                ),
                                              ),
                                              focusedBorder: OutlineInputBorder(
                                                // 用来配置输入框获取焦点时的颜色
                                                borderRadius: BorderRadius.all(
                                                    Radius.circular(
                                                        0)), // 设置边框四个角的弧度
                                                borderSide: BorderSide(
                                                  // 用来配置边框的样式
                                                  color: Colors
                                                      .transparent, // 设置边框的颜色
                                                  width: setWidth(1), // 设置边框的粗细
                                                ),
                                              ),
                                              disabledBorder:
                                                  OutlineInputBorder(
                                                // 设置输入框可编辑时的边框样式
                                                borderRadius: BorderRadius.all(
                                                    Radius.circular(
                                                        0)), // 设置边框四个角的弧度
                                                borderSide: BorderSide(
                                                  // 用来配置边框的样式
                                                  color: Colors
                                                      .transparent, // 设置边框的颜色
                                                  width: setWidth(1), // 设置边框的粗细
                                                ),
                                              ),
                                            ),
                                          ),
                                        ),
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                              Divider(
                                height: setWidth(1),
                                color: Color(0xffEEEEEE),
                                indent: setWidth(38),
                                endIndent: 0,
                              ),
                              // 性别
                              Container(
                                height: setWidth(88),
                                padding: EdgeInsets.symmetric(
                                    horizontal: setWidth(50)),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  children: [
                                    Container(
                                      width: setWidth(156),
                                      alignment: Alignment.centerLeft,
                                      child: Row(
                                        children: [
                                          Text(
                                            '性别',
                                            style: TextStyle(
                                              color: Color(0xff333333),
                                              fontSize: 13,
                                            ),
                                          ),
                                          Text(
                                            '*',
                                            style: TextStyle(
                                              color: Colors.red,
                                              fontSize: 13,
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                      child: Container(
                                        child: Row(
                                          mainAxisAlignment:
                                              MainAxisAlignment.start,
                                          children: [
                                            InkWell(
                                              onTap: () {
                                                print('保密点击事件！！！');
                                                if (state.genderIndex != 0) {
                                                  setState(() {
                                                    state.genderIndex = 0;
                                                  });
                                                }
                                              },
                                              child: Container(
                                                height: setWidth(88),
                                                width: setWidth(96),
                                                child: Row(
                                                  mainAxisAlignment:
                                                      MainAxisAlignment
                                                          .spaceBetween,
                                                  crossAxisAlignment:
                                                      CrossAxisAlignment.center,
                                                  children: [
                                                    Image.asset(
                                                      state.genderIndex == 0
                                                          ? 'assets/images/selectIcon1.png'
                                                          : 'assets/images/save.png',
                                                      width: setWidth(28),
                                                      height: setWidth(28),
                                                      fit: BoxFit.cover,
                                                    ),
                                                    Text(
                                                      '保密',
                                                      style: TextStyle(
                                                        color:
                                                            Color(0xff222222),
                                                        fontSize: 13,
                                                      ),
                                                    ),
                                                  ],
                                                ),
                                              ),
                                            ),
                                            SizedBox(
                                              width: setWidth(30),
                                            ),
                                            InkWell(
                                              onTap: () {
                                                print('男 点击事件！！！');
                                                if (state.genderIndex != 1) {
                                                  setState(() {
                                                    state.genderIndex = 1;
                                                  });
                                                }
                                              },
                                              child: Container(
                                                height: setWidth(88),
                                                width: setWidth(96),
                                                child: Row(
                                                  mainAxisAlignment:
                                                      MainAxisAlignment
                                                          .spaceBetween,
                                                  crossAxisAlignment:
                                                      CrossAxisAlignment.center,
                                                  children: [
                                                    Image.asset(
                                                      state.genderIndex == 1
                                                          ? 'assets/images/selectIcon1.png'
                                                          : 'assets/images/save.png',
                                                      width: setWidth(28),
                                                      height: setWidth(28),
                                                      fit: BoxFit.cover,
                                                    ),
                                                    Text(
                                                      '男',
                                                      style: TextStyle(
                                                        color:
                                                            Color(0xff222222),
                                                        fontSize: 13,
                                                      ),
                                                    ),
                                                  ],
                                                ),
                                              ),
                                            ),
                                            SizedBox(
                                              width: setWidth(30),
                                            ),
                                            InkWell(
                                              onTap: () {
                                                print('女 点击事件！！！');
                                                if (state.genderIndex != 2) {
                                                  setState(() {
                                                    state.genderIndex = 2;
                                                  });
                                                }
                                              },
                                              child: Container(
                                                height: setWidth(88),
                                                width: setWidth(96),
                                                child: Row(
                                                  mainAxisAlignment:
                                                      MainAxisAlignment
                                                          .spaceBetween,
                                                  crossAxisAlignment:
                                                      CrossAxisAlignment.center,
                                                  children: [
                                                    Image.asset(
                                                      state.genderIndex == 2
                                                          ? 'assets/images/selectIcon1.png'
                                                          : 'assets/images/save.png',
                                                      width: setWidth(28),
                                                      height: setWidth(28),
                                                      fit: BoxFit.cover,
                                                    ),
                                                    Text(
                                                      '女',
                                                      style: TextStyle(
                                                        color:
                                                            Color(0xff222222),
                                                        fontSize: 13,
                                                      ),
                                                    ),
                                                  ],
                                                ),
                                              ),
                                            ),
                                          ],
                                        ),
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                              Divider(
                                height: setWidth(1),
                                color: Color(0xffEEEEEE),
                                indent: setWidth(38),
                                endIndent: 0,
                              ),
                              // Email
                              Container(
                                height: setWidth(88),
                                padding: EdgeInsets.symmetric(
                                    horizontal: setWidth(50)),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  children: [
                                    Container(
                                      width: setWidth(156),
                                      alignment: Alignment.centerLeft,
                                      child: Text(
                                        'Email',
                                        style: TextStyle(
                                          color: Color(0xff333333),
                                          fontSize: 13,
                                        ),
                                      ),
                                    ),
                                    Expanded(
                                      child: Container(
                                        child: TextField(
                                          controller: state.emailController,
                                          style: TextStyle(
                                            color: Color(0xff222222),
                                            fontSize: 13,
                                          ),
                                          maxLines: 1,
                                          decoration: InputDecoration(
                                            fillColor: Colors.white,
                                            filled: true,
                                            contentPadding: EdgeInsets.zero,
                                            hintText: '请输入email',
                                            hintStyle: TextStyle(
                                              color: Color(0xffcccccc),
                                              fontSize: 13,
                                            ),
                                            enabledBorder: OutlineInputBorder(
                                              // 设置输入框可编辑时的边框样式
                                              borderRadius: BorderRadius.all(
                                                  Radius.circular(
                                                      0)), // 设置边框四个角的弧度
                                              borderSide: BorderSide(
                                                // 用来配置边框的样式
                                                color: Colors
                                                    .transparent, // 设置边框的颜色
                                                width: setWidth(1), // 设置边框的粗细
                                              ),
                                            ),
                                            focusedBorder: OutlineInputBorder(
                                              // 用来配置输入框获取焦点时的颜色
                                              borderRadius: BorderRadius.all(
                                                  Radius.circular(
                                                      0)), // 设置边框四个角的弧度
                                              borderSide: BorderSide(
                                                // 用来配置边框的样式
                                                color: Colors
                                                    .transparent, // 设置边框的颜色
                                                width: setWidth(1), // 设置边框的粗细
                                              ),
                                            ),
                                          ),
                                        ),
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                              Divider(
                                height: setWidth(1),
                                color: Color(0xffEEEEEE),
                                indent: setWidth(38),
                                endIndent: 0,
                              ),
                              // 感兴趣的领域
                              Container(
                                constraints: BoxConstraints(
                                  minHeight: setWidth(88),
                                ),
                                padding: EdgeInsets.symmetric(
                                    horizontal: setWidth(50)),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  children: [
                                    Container(
                                      width: setWidth(156),
                                      alignment: Alignment.centerLeft,
                                      child: Text(
                                        '感兴趣的领域',
                                        style: TextStyle(
                                          color: Color(0xff333333),
                                          fontSize: 13,
                                        ),
                                      ),
                                    ),
                                    Expanded(
                                      child: InkWell(
                                        onTap: () {
                                          print('点击选择，支持多选  点击事件！！！');
                                          showDialog(
                                            context: context,
                                            useSafeArea: false,
                                            builder: (context) {
                                              int index = 0;
                                              state.areasInterestList
                                                  .map((dict) {
                                                if (dict['chooseBool']) {
                                                  index++;
                                                }
                                              }).toList();
                                              return AreasInterestWidget(
                                                array: state.areasInterestList,
                                                chooseNum: index,
                                              );
                                            },
                                          );
                                        },
                                        child: Container(
                                          alignment: Alignment.centerLeft,
                                          padding: EdgeInsets.symmetric(
                                              vertical: setWidth(7)),
                                          child: Text(
                                            state.areasInterestStr == ''
                                                ? '点击选择，支持多选'
                                                : state.areasInterestStr,
                                            style: TextStyle(
                                              color:
                                                  state.areasInterestStr == ''
                                                      ? Color(0xffcccccc)
                                                      : Color(0xff222222),
                                              fontSize: 13,
                                            ),
                                          ),
                                        ),
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                              Divider(
                                height: setWidth(1),
                                color: Color(0xffEEEEEE),
                                indent: setWidth(38),
                                endIndent: 0,
                              ),
                              // 城市
                              Container(
                                height: setWidth(88),
                                padding: EdgeInsets.symmetric(
                                    horizontal: setWidth(50)),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  children: [
                                    Container(
                                      width: setWidth(156),
                                      alignment: Alignment.centerLeft,
                                      child: Row(
                                        children: [
                                          Text(
                                            '城市',
                                            style: TextStyle(
                                              color: Color(0xff333333),
                                              fontSize: 13,
                                            ),
                                          ),
                                          Text(
                                            '*',
                                            style: TextStyle(
                                              color: Colors.red,
                                              fontSize: 13,
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                      child: InkWell(
                                        onTap: () async {
                                          print('选择城市');
                                          final res =
                                              await KzcityPicker.showPicker(
                                            context,
                                            datas: state.addressList,
                                          );
                                          print(res.province +
                                              '  ' +
                                              res.city +
                                              '  ' +
                                              res.area +
                                              '  ' +
                                              res.provinceCode +
                                              '  ' +
                                              res.cityCode +
                                              '  ' +
                                              res.areaCode);
                                          setState(() {
                                            state.cityController.text =
                                                '${res.province} ${res.city} ${res.area}';
                                            state.provinceStr =
                                                res.provinceCode;
                                            state.cityStr = res.cityCode;
                                            state.areaStr = res.areaCode;
                                          });
                                        },
                                        child: Container(
                                          child: TextField(
                                            controller: state.cityController,
                                            style: TextStyle(
                                              color: Color(0xff222222),
                                              fontSize: 13,
                                            ),
                                            maxLines: 2,
                                            enabled: false,
                                            decoration: InputDecoration(
                                              fillColor: Colors.white,
                                              filled: true,
                                              contentPadding: EdgeInsets.zero,
                                              hintText: '点击选择地区',
                                              hintStyle: TextStyle(
                                                color: Color(0xffcccccc),
                                                fontSize: 13,
                                              ),
                                              enabledBorder: OutlineInputBorder(
                                                // 设置输入框可编辑时的边框样式
                                                borderRadius: BorderRadius.all(
                                                    Radius.circular(
                                                        0)), // 设置边框四个角的弧度
                                                borderSide: BorderSide(
                                                  // 用来配置边框的样式
                                                  color: Colors
                                                      .transparent, // 设置边框的颜色
                                                  width: setWidth(1), // 设置边框的粗细
                                                ),
                                              ),
                                              focusedBorder: OutlineInputBorder(
                                                // 用来配置输入框获取焦点时的颜色
                                                borderRadius: BorderRadius.all(
                                                    Radius.circular(
                                                        0)), // 设置边框四个角的弧度
                                                borderSide: BorderSide(
                                                  // 用来配置边框的样式
                                                  color: Colors
                                                      .transparent, // 设置边框的颜色
                                                  width: setWidth(1), // 设置边框的粗细
                                                ),
                                              ),
                                              disabledBorder:
                                                  OutlineInputBorder(
                                                // 设置输入框可编辑时的边框样式
                                                borderRadius: BorderRadius.all(
                                                    Radius.circular(
                                                        0)), // 设置边框四个角的弧度
                                                borderSide: BorderSide(
                                                  // 用来配置边框的样式
                                                  color: Colors
                                                      .transparent, // 设置边框的颜色
                                                  width: setWidth(1), // 设置边框的粗细
                                                ),
                                              ),
                                            ),
                                          ),
                                        ),
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                              Divider(
                                height: setWidth(1),
                                color: Color(0xffEEEEEE),
                                indent: setWidth(38),
                                endIndent: 0,
                              ),
                              // 地址
                              Container(
                                height: setWidth(88),
                                padding: EdgeInsets.symmetric(
                                    horizontal: setWidth(50)),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  children: [
                                    Container(
                                      width: setWidth(156),
                                      alignment: Alignment.centerLeft,
                                      child: Row(
                                        children: [
                                          Text(
                                            '地址',
                                            style: TextStyle(
                                              color: Color(0xff333333),
                                              fontSize: 13,
                                            ),
                                          ),
                                          Text(
                                            '*',
                                            style: TextStyle(
                                              color: Colors.red,
                                              fontSize: 13,
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                    Expanded(
                                      child: Container(
                                        child: TextField(
                                          controller: state.addressController,
                                          style: TextStyle(
                                            color: Color(0xff222222),
                                            fontSize: 13,
                                          ),
                                          maxLines: 1,
                                          decoration: InputDecoration(
                                            fillColor: Colors.white,
                                            filled: true,
                                            contentPadding: EdgeInsets.zero,
                                            hintText: '请输入详细地址',
                                            hintStyle: TextStyle(
                                              color: Color(0xffcccccc),
                                              fontSize: 13,
                                            ),
                                            enabledBorder: OutlineInputBorder(
                                              // 设置输入框可编辑时的边框样式
                                              borderRadius: BorderRadius.all(
                                                  Radius.circular(
                                                      0)), // 设置边框四个角的弧度
                                              borderSide: BorderSide(
                                                // 用来配置边框的样式
                                                color: Colors
                                                    .transparent, // 设置边框的颜色
                                                width: setWidth(1), // 设置边框的粗细
                                              ),
                                            ),
                                            focusedBorder: OutlineInputBorder(
                                              // 用来配置输入框获取焦点时的颜色
                                              borderRadius: BorderRadius.all(
                                                  Radius.circular(
                                                      0)), // 设置边框四个角的弧度
                                              borderSide: BorderSide(
                                                // 用来配置边框的样式
                                                color: Colors
                                                    .transparent, // 设置边框的颜色
                                                width: setWidth(1), // 设置边框的粗细
                                              ),
                                            ),
                                          ),
                                        ),
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                              Divider(
                                height: setWidth(1),
                                color: Color(0xffEEEEEE),
                                indent: setWidth(38),
                                endIndent: 0,
                              ),
                              SizedBox(
                                height: setWidth(40),
                              ),
                            ],
                          ),
                        ),
                        SizedBox(
                          height: setWidth(40),
                        ),
                        Container(
                          padding: EdgeInsets.only(
                              left: setWidth(50), right: setWidth(50)),
                          child: InkWell(
                            onTap: () {
                              print('+++++++++++++ 保存 点击按钮 +++++++++++++');
                              logic.modifyInformation(context);
                            },
                            child: Container(
                              height: setWidth(80),
                              decoration: BoxDecoration(
                                color: Color(0xffEA5504),
                                borderRadius:
                                    BorderRadius.circular(setWidth(40)),
                              ),
                              alignment: Alignment.center,
                              child: Text(
                                '保存',
                                style: TextStyle(
                                  color: Colors.white,
                                  fontSize: 17,
                                ),
                              ),
                            ),
                          ),
                        ),
                        SizedBox(
                          height: setWidth(100),
                        ),
                      ],
                    ),
                  ),
                ),
                /* Container(
                  height: setWidth(120),
                  padding: EdgeInsets.only(
                    left: setWidth(50),
                    top: setWidth(20),
                    right: setWidth(50),
                    bottom: setWidth(22),
                  ),
                  decoration: BoxDecoration(
                    color: Colors.white,
                    border: Border(
                      top: BorderSide(
                        color: Color(0x1AEA5504),
                        width: setWidth(1),
                      ),
                    ),
                  ),
                  child: InkWell(
                    onTap: () {
                      print('+++++++++++++ 保存 点击按钮 +++++++++++++');
                      logic.modifyInformation(context);
                    },
                    child: Container(
                      height: setWidth(80),
                      decoration: BoxDecoration(
                        color: Color(0xffEA5504),
                        borderRadius: BorderRadius.circular(setWidth(40)),
                      ),
                      alignment: Alignment.center,
                      child: Text(
                        '保存',
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 17,
                        ),
                      ),
                    ),
                  ),
                ), */
              ],
            ),
          );
        },
      ),
    );
  }

  //照片选择
  void selectImage(BuildContext context) {
    //用于在底部打开弹框的效果
    showModalBottomSheet(
      builder: (BuildContext context) {
        //构建弹框中的内容
        return Container(
          height: 300.w,
          child: Column(
            children: [
              Container(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: [
                    InkWell(
                      onTap: () {
                        loadAssets(1);
                      },
                      child: Container(
                        height: 90.w,
                        width: 750.w,
                        decoration: BoxDecoration(
                          border: Border(
                            bottom: BorderSide(
                              color: Color(0xffeeeeee),
                              width: 1.w,
                            ),
                          ),
                        ),
                        child: Center(
                          child: Text(
                            "拍摄",
                            style: TextStyle(
                              // color: Color(0xff2222),
                              color: Colors.black,
                              fontSize: 32.sp,
                            ),
                            textAlign: TextAlign.center,
                          ),
                        ),
                      ),
                    ),
                    InkWell(
                      onTap: () {
                        loadAssets(2);
                      },
                      child: Container(
                        height: 90.w,
                        width: 750.w,
                        child: Center(
                          child: Text(
                            "从手机相册选择",
                            style: TextStyle(
                              // color: Color(0xff2222),
                              color: Colors.black,
                              fontSize: 32.sp,
                            ),
                            textAlign: TextAlign.center,
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
              Container(
                color: Color(0xffF2F3F4),
                height: 20.w,
              ),
              Expanded(
                child: InkWell(
                  onTap: () {
                    Navigator.of(context).pop();
                  },
                  child: Container(
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: [
                        Container(
                          height: 90.w,
                          width: 750.w,
                          child: Center(
                            child: Text(
                              "取消",
                              style: TextStyle(
                                // color: Color(0xff2222),
                                color: Colors.black,
                                fontSize: 32.sp,
                              ),
                              textAlign: TextAlign.center,
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              )
            ],
          ),
        );
      },
      context: context,
    );
  }
}

class AreasInterestWidget extends StatefulWidget {
  final List array;
  final int chooseNum;

  AreasInterestWidget({this.array, this.chooseNum});
  @override
  State<StatefulWidget> createState() {
    return _AreasInterestWidgetState(chooseNum, array);
  }
}

class _AreasInterestWidgetState extends State<AreasInterestWidget> {
  final MemberInformationLogic logic = Get.put(MemberInformationLogic());
  int index;
  List arrayDict;
  _AreasInterestWidgetState(this.index, this.arrayDict);

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      mainAxisAlignment: MainAxisAlignment.end,
      children: [
        Container(
          color: Colors.white,
          width: MediaQuery.of(context).size.width,
          padding: EdgeInsets.symmetric(horizontal: setWidth(40)),
          constraints: BoxConstraints(
            minHeight: setWidth(600),
          ),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Padding(
                padding: EdgeInsets.only(
                  top: setWidth(34),
                  bottom: setWidth(50),
                ),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Text(
                      '选择感兴趣的领域',
                      style: TextStyle(
                        color: Color(0xff666666),
                        fontSize: 14,
                        decoration: TextDecoration.none,
                      ),
                    ),
                  ],
                ),
              ),
              Wrap(
                spacing: setWidth(20),
                runSpacing: setWidth(15),
                children: arrayDict
                    .asMap()
                    .map((key, value) {
                      Map<String, dynamic> areasInterestMap = value;
                      String areasInterestStr = areasInterestMap['nameStr'];
                      bool areasInterestBool = areasInterestMap['chooseBool'];
                      return MapEntry(
                        key,
                        Row(
                          mainAxisSize: MainAxisSize.min,
                          children: [
                            GestureDetector(
                              onTap: () {
                                print('兴趣选中  value = $value,  key = $key');
                                Map arrayMap = arrayDict[key];
                                if (arrayMap['chooseBool']) {
                                  --index;
                                } else {
                                  ++index;
                                }
                                arrayMap['chooseBool'] =
                                    !arrayMap['chooseBool'];
                                setState(() {});
                              },
                              behavior: HitTestBehavior.opaque,
                              child: Container(
                                height: setWidth(64),
                                padding: EdgeInsets.symmetric(
                                    horizontal: setWidth(32)),
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(10),
                                  border: Border.all(
                                    color: areasInterestBool
                                        ? Color(0xffEA5504)
                                        : Color(0xffCCCCCC),
                                    width: setWidth(2),
                                  ),
                                ),
                                alignment: Alignment.center,
                                child: Text(
                                  areasInterestStr,
                                  style: TextStyle(
                                    color: areasInterestBool
                                        ? Color(0xffEA5504)
                                        : Color(0xffCCCCCC),
                                    fontSize: 14,
                                    decoration: TextDecoration.none,
                                  ),
                                ),
                              ),
                            ),
                          ],
                        ),
                      );
                    })
                    .values
                    .toList(),
              ),
              Padding(
                padding: EdgeInsets.only(
                  top: setWidth(40),
                  bottom: setWidth(80),
                ),
                child: Text(
                  '已选：$index个领域',
                  style: TextStyle(
                    color: Color(0xff666666),
                    fontSize: 12,
                    decoration: TextDecoration.none,
                  ),
                ),
              ),
              GestureDetector(
                onTap: () {
                  print('确定 按钮点击事件！！！');
                  String titleStr = '';
                  for (int i = 0; i < arrayDict.length; i++) {
                    Map<String, dynamic> mapData = arrayDict[i];
                    if (mapData['chooseBool'] == true) {
                      if (titleStr == '') {
                        titleStr = mapData['nameStr'];
                      } else {
                        titleStr = '$titleStr, ${mapData['nameStr']}';
                      }
                    }
                  }
                  logic.onAreasInterestClick(areasInterestStr: titleStr);
                  Navigator.pop(context);
                },
                behavior: HitTestBehavior.opaque,
                child: Container(
                  height: setWidth(80),
                  decoration: BoxDecoration(
                    color: Color(0xffEA5504),
                    borderRadius: BorderRadius.circular(setWidth(40)),
                  ),
                  alignment: Alignment.center,
                  child: Text(
                    '确定',
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 17,
                      decoration: TextDecoration.none,
                    ),
                  ),
                ),
              ),
              SizedBox(
                height: setWidth(40),
              ),
            ],
          ),
        ),
      ],
    );
  }
}
